<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="/WEB-INF/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta name="renderer" content="ie-comp">
<html>
<head>
    <title>新增</title>
    <%@ include file="/WEB-INF/jsp/include.jsp" %>
    <script type="text/javascript"
            src="${path}/resource/js/jquery/jquery-easyui-1.4.5/extends/jquery.layout.extend.js"></script>
    <script type="text/javascript">
        var path = "${path}";
        var params = new Object();
        var url = path + "/system/cronjob/add";


        $(function () {
            $("#dlg2").css("display", "none");
            $("#dlg1").css("display", "none");
            params.timeSet = "02";
            $("#timeSet").combobox({
                onChange: function (dictCode, o) {
                    if (dictCode == "服务调度") {
                        $("#dlg").css("display", "block");
                        $("#dlg1").css("display", "none");
                        $("#dlg2").css("display", "none");
                        params.timeSet = "02";
                    } else if (dictCode == "存储过程调度") {
                        $("#dlg1").css("display", "block");
                        $("#dlg2").css("display", "none");
                        $("#dlg").css("display", "none");
                        params.timeSet = "03";
                    }
                }

            });

        });


        function btnUpdateCron() {
            parent.layer.open({
                type: 2,
                title: '更新cron',
                shadeClose: false,
                shade: 0.6,
                area: ['860px', '510px'],
                content: '${path}/system/cronjob/toAddCron?win=' + window.name,
                success: function (layero, index) {
                },
                end: function () {
                   // $.parser.parse();
                }
            });
        }

        //提交
        function btnSubmitAdd() {
            if (!validform("jsForm")) {
                return;
            }
            var TimeEffect = $("#TimeEffectStr").datetimebox("getValue");
            var TimeLose = $("#TimeLoseStr").datetimebox("getValue");
            params.TimeEffectStr = TimeEffect;
            params.TimeLoseStr = TimeLose;
            if(TimeEffect !=null && TimeLose != null && TimeEffect !="" && TimeLose != ""){
                if(TimeEffect >=TimeLose){
                    return $.alert("default", "info", "结束时间要大于开始时间！");
                }
            }

            if (tpye = "02") {
                params.beanId = $("#beanId").val();
                params.methodCall = $("#methodCall").val();
            }
            if (tpye = "03") {
                params.storedName = $("#storedName").val();
                params.dataSource = $("#dataSource").val();
            }
            //设置任务状态
            if ($("#validMark").val() == "启动") {
                params.validMark = "1";
            } else if ($("#validMark").val() == "停止") {
                params.validMark = "0";
            }
            //设置是否有串并行
            if ($("#isConcurrent").val() == "否") {
                params.isConcurrent = "1";
            } else if ($("#isConcurrent").val() == "是") {
                params.isConcurrent = "0";
            }
            $("#jsForm").ajaxSubmit({
                type: "POST",
                url: url,
                dataType: "json",
                data: params,
                async: false,
                success: function callback(data) {
                    var analyMsg = data;
                    if (analyMsg.code != '0000') {
                        if (analyMsg.code != "0002") {
                            $.messager.alert('操作提示', analyMsg.msg, 'error', function () {
                            });
                        } else {
                            $.messager.alert('操作提示', analyMsg.msg, 'info', function () {
                            });
                        }
                    } else {
                        $.messager.alert("操作提示", "添加信息成功！", "info", function () {
                            parent.btnQuery();
                            setTimeout("closeLayer()", 100);//设置延时，防止IE下出现异常
                        });
                    }
                },
                error: function (data, textstatus) {
                    $.messager.alert('操作提示', data.responseText, 'info', function () {
                    });
                }
            });
        }
        function btnCancelAdd() {
            closeLayer();
        }
    </script>
</head>
<body style="margin:5px; padding:0px;">
<input type="hidden" id="txt_id"/>
<div class="easyui-layout" fit="true">
    <div id="AddDlgDiv" data-options="region:'north',title:'设置主体',split:false,border: true"
         style="padding: 5px; height: 245px; background: none repeat scroll 0 0 #EFEFEF;">
        <form id="jsForm" method="post">
            <table class="f_table" cellspacing="1" align="center">
                <colgroup>
                    <col style="width:160px;"></col>
                    <col style="width:260px;"></col>
                    <col style="width:160px;"></col>
                    <col style="width:260px;"></col>
                </colgroup>
                <tr>
                    <td align="right" class="s_bg" style="width:133px">任务名称：</td>
                    <td class="s_bg" style="width: 160px">
                        <input type="text" id="jobName" name="jobName" class="easyui-validatebox"
                               data-options="required:true,validType:'maxLength[60]'" style="width: 98%;"/></td>
                    <td align="right" class="s_bg" style="width:133px">任务分组：</td>
                    <td class="s_bg" style="width: 160px">
                        <input type="text" id="jobGroup" name="jobGroup" class="easyui-validatebox"
                               data-options="required:true,validType:'maxLength[100]'" style="width: 98%;"/></td>
                </tr>
                <tr>
                    <td align="right" class="s_bg" style="width:133px">调度类型：</td>
                    <td class="s_bg" style="width: 160px;">
                        <select id="timeSet" class="easyui-validatebox"
                                data-options="required:true,tipPosition:'left'" style="width: 98%;">
                            <option>服务调度</option>
                            <option>存储过程调度</option>
                        </select></td>
                    <td align="right" class="s_bg" style="width:133px">&nbsp;&nbsp;有效时间区间：</td>
                    <td><input id="TimeEffectStr" class="easyui-datetimebox" editable="true" style="width:110px"/>&nbsp;&nbsp;-
                    <input id="TimeLoseStr" class="easyui-datetimebox" editable="false" style="width:110px"/></td>
                </tr>
                <tr>
                    <td align="right" class="s_bg" style="width:133px">任务是否串行：</td>
                    <td class="s_bg" style="width: 160px;">
                        <select id="isConcurrent" class="easyui-validatebox"
                                data-options="required:true,tipPosition:'left'" style="width: 98%;">
                            <option>是</option>
                            <option>否</option>
                        </select></td>
                    <td align="right" class="s_bg" style="width:133px">任务状态：</td>
                    <td><select id="validMark" class="easyui-validatebox"
                                data-options="required:true,tipPosition:'left'"
                                style="width: 98%;">
                        <option>停止</option>
                        <option>启动</option>
                    </select></td>
                </tr>
                <tr>
                    <td align="right" class="s_bg" style="width:133px">cron表达式：</td>
                    <td class="s_bg" style="width: 160px;">
                        <input type="text" id="cron" name="cron" readOnly="readOnly" class="easyui-validatebox"
                               data-options="required:true,validType:'maxLength[60]'" style="width:98%;"/></td>
                    <td class="s_bg" style="width: 160px;" colspan="2">
                        <span type="button" style="text-decoration: underline;" onclick="btnUpdateCron()">设置</span>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="s_bg" style="width:133px">描述：</td>
                    <td class="s_bg" style="width: 160px; " colspan="5">
                        <input type="text" id="remark" name="remark" class="easyui-validatebox"
                               data-options="required:true,validType:'maxLength[200]'" style="width:98%;"/></td>
                </tr>
            </table>

        </form>
    </div>

    <div region="center" style="padding: 5px;" border="false">
        <div id="cc" class="easyui-layout" fit="true" border="false">
            <div data-options="region:'center',title:'调度详情'" border="true" noheader="true" split="false"  style="width:50%;">
                <div class="easyui-layout" fit="true"  border="false">
                    <div region="center" class ="panel-title" title="调度详情" border="false" style="height:50%;">
                        <%--隐藏和显示的div--%>
                        <div id="dlg">
                            <table class="f_table" cellspacing="1" align="center">
                                <colgroup>
                                    <col style="width:160px;"></col>
                                    <col style="width:260px;"></col>
                                    <col style="width:160px;"></col>
                                    <col style="width:260px;"></col>
                                </colgroup>
                                <tr>
                                    <td align="right" class="s_bg" style="width:133px">BEAN_ID：</td>
                                    <td class="s_bg" style="width: 160px;">
                                        <input type="text" id="beanId" name="beanId" class="easyui-validatebox"
                                               data-options="validType:['maxLength[60]','onSpringId']"
                                               style="width:98%;"/></td>
                                    <td align="right" class="s_bg" style="width:133px">方法名：</td>
                                    <td class="s_bg" style="width: 160px;">
                                        <input type="text" id="methodCall" name="methodCall" class="easyui-validatebox"
                                               data-options="required:true,validType:'maxLength[20]'" style="width:98%;"/></td>
                                </tr>
                            </table>
                        </div>


                        <div id="dlg1">
                            <table class="f_table" cellspacing="1" align="center">
                                <colgroup>
                                    <col style="width:160px;"></col>
                                    <col style="width:260px;"></col>
                                    <col style="width:160px;"></col>
                                    <col style="width:260px;"></col>
                                </colgroup>
                                <tr>
                                    <td align="right" class="s_bg" style="width:133px">数据源名称：</td>
                                    <td class="s_bg" style="width: 160px;">
                                        <input type="text" id="dataSource" name="beanId" class="easyui-validatebox"
                                               data-options="validType:['maxLength[100]','onSpringId']"
                                               style="width:98%;"/></td>
                                    <td align="right" class="s_bg" style="width:133px">存储过程名称：</td>
                                    <td class="s_bg" style="width: 160px;">
                                        <input type="text" id="storedName" name="methodCall" class="easyui-validatebox"
                                               data-options="required:true,validType:'maxLength[20]'" style="width:98%;"/></td>
                                </tr>
                                <tr>
                            </table>
                        </div>
                    </div>
                </div>

            </div>

        </div>
    </div>


    <div data-options="region:'south',title:'',split:false,border: false" style="height:55px;">
        <div align="center" style="margin-top: 15px;">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="btnSubmitAdd()">确定</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel"
               onclick="btnCancelAdd();">取消</a>
        </div>
    </div>

</div>
</body>
</html>
